package com.lk.netty.encode;

import com.lk.netty.message.UserMessage;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.CharsetUtil;

public class UserMessageEncode extends MessageToByteEncoder<UserMessage> {

    @Override
    protected void encode(ChannelHandlerContext ctx, UserMessage msg, ByteBuf out) {
        out.writeCharSequence(msg.getUsername(), CharsetUtil.UTF_8);
    }
}

